package com.ruoyi.labdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabReservationParameterPersonnel;
import com.ruoyi.labdata.service.ILabReservationParameterPersonnelService;

/**
 * 预约及参数人员Controller
 *
 * @author ruoyi
 * @date 2022-03-29
 */
@RestController
@RequestMapping("/labdata/reservationPersonnel")
public class LabReservationParameterPersonnelController extends BaseController {
    @Autowired
    private ILabReservationParameterPersonnelService labReservationParameterPersonnelService;

    /**
     * 查询预约及参数人员列表
     */
    @PreAuthorize("@ss.hasPermi('labdata:reservation:query')")
    @GetMapping("/list")
    public TableDataInfo list(LabReservationParameterPersonnel labReservationParameterPersonnel) {
        startPage();
        List<LabReservationParameterPersonnel> list = labReservationParameterPersonnelService.selectLabReservationParameterPersonnelList(labReservationParameterPersonnel);
        return getDataTable(list);
    }

    /**
     * 导出预约及参数人员列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:reservationPersonnel:export')")
   /* @Log(title = "预约及参数人员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabReservationParameterPersonnel labReservationParameterPersonnel) {
        List<LabReservationParameterPersonnel> list = labReservationParameterPersonnelService.selectLabReservationParameterPersonnelList(labReservationParameterPersonnel);
        ExcelUtil<LabReservationParameterPersonnel> util = new ExcelUtil<LabReservationParameterPersonnel>(LabReservationParameterPersonnel.class);
        return util.exportExcel(list, "reservationPersonnel");
    }*/

    /**
     * 获取预约及参数人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:reservation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(labReservationParameterPersonnelService.selectLabReservationParameterPersonnelById(id));
    }

    /**
     * 新增预约及参数人员
     */
    @PreAuthorize("@ss.hasPermi('labdata:reservation:edit')")
    @Log(title = "预约及参数人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabReservationParameterPersonnel labReservationParameterPersonnel) {
        return toAjax(labReservationParameterPersonnelService.insertLabReservationParameterPersonnel(labReservationParameterPersonnel));
    }

    /**
     * 修改预约及参数人员
     */
    @PreAuthorize("@ss.hasPermi('labdata:reservation:edit')")
    @Log(title = "预约及参数人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabReservationParameterPersonnel labReservationParameterPersonnel) {
        return toAjax(labReservationParameterPersonnelService.updateLabReservationParameterPersonnel(labReservationParameterPersonnel));
    }

    /**
     * 删除预约及参数人员
     */
    @PreAuthorize("@ss.hasPermi('labdata:reservation:edit')")
    @Log(title = "预约及参数人员", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(labReservationParameterPersonnelService.deleteLabReservationParameterPersonnelByIds(ids));
    }
}
